package game.classes.particles.displays
{
	import flash.display.Shape;
	import flash.display.Sprite;
	
	import net.richardlord.asteroids.components.ColorType;
	import net.richardlord.asteroids.components.LensType;

	public class Mirror extends Sprite implements Animatable
	{	
		public static const LEGS:String = "legs";
		public static const BASE:String = "base";
		public static const COLOR:String = "color";
		public static const MIRROR:String = "mirror";
		
		public var color:uint;
		public var lens:LensType;
		
		public function Mirror(radius:Number, color:uint, lens:LensType)
		{
			this.color = color;
			this.lens = lens;
			
			var shape:Shape = new Shape();
			shape.name = Mirror.LEGS;
			shape.graphics.beginFill(0x333333);
			shape.graphics.drawRect(-radius*0.125, -radius*1.5, radius*0.25, radius*3);
			shape.graphics.drawRect(-radius*1.5, -radius*0.125, radius*3, radius*0.25);
			shape.graphics.endFill();
			shape.rotation += 45;
			this.addChild(shape);
			
			shape = new Shape();
			shape.name = Mirror.BASE;
			shape.graphics.beginFill(0x333333);
			shape.graphics.drawCircle( 0, 0, radius );
			shape.graphics.endFill();
			this.addChild( shape );
			
			shape = new Shape();
			shape.name = Mirror.COLOR;
			shape.graphics.beginFill(this.color.type);
			shape.graphics.drawCircle( 0, 0, radius * 0.65 );
			shape.graphics.endFill();
			this.addChild( shape );
			
			shape = new Shape();
			shape.name = Mirror.MIRROR;
			shape.graphics.beginFill(0xFFFFFF, 0.65);
			switch(this.lens)
			{
				case LensType.CONVEX:
					shape.graphics.moveTo(0, -radius*2);
					shape.graphics.curveTo(-radius/2, 0, 0, radius*2);
					shape.graphics.curveTo(radius/2, 0, 0, -radius*2);
					shape.graphics.endFill();
					break;
				case LensType.CONCAVE:
					shape.graphics.moveTo(-radius/4, -radius*2);
					shape.graphics.curveTo(radius/8, 0, -radius/4, radius*2);
					shape.graphics.lineTo(radius/4, radius*2);
					shape.graphics.curveTo(-radius/8, 0, radius/4, -radius*2);
					shape.graphics.lineTo(-radius/4, -radius*2);
					shape.graphics.endFill();
					break;
				case LensType.REFLECTIVE:
					shape.graphics.drawRect(-radius/4, -radius*2, radius/2, radius*4);
					shape.graphics.endFill();
					break;	
			}
			this.addChild(shape);
		}
		
		public function animate(time:Number):void
		{
			
		}
	}
}
